/*
 * @Author: your name
 * @Date: 2024-05-13 10:19:53
 * @LastEditTime: 2024-05-13 10:29:32
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\491.非递减子序列.cpp
 */
/*
 * @lc app=leetcode.cn id=491 lang=cpp
 *
 * [491] 非递减子序列
 */

// @lc code=start
class Solution {
public:
    vector<vector<int>> res;
    vector<int> path;
    void backtracking(vector<int>& nums, int startIndex){
        if(path.size() > 1){
            res.push_back(path);
        }
        int used[201] = {0};
        for(int i = startIndex; i < nums.size(); i++){
            if((!path.empty() && nums[i] < path.back()) || used[nums[i]+100] != 0 ){
                continue;
            }
            used[nums[i]+100] = 1;
            path.push_back(nums[i]);
            backtracking(nums, i+1);
            path.pop_back();
        }
    }
    vector<vector<int>> findSubsequences(vector<int>& nums) {
        backtracking(nums, 0);
        return res;
    }
};
// @lc code=end

